package com.ykw.parking.mapper;

import com.ykw.parking.pojo1.*;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface UserMapper {
    public User queryUserbyname(String name);
    public User queryUserbyemail(String email);
    public void insertUser(String id,String name,String phone_number,String password,String email,Integer state);
    @Insert("insert into users.user value(#{id},#{name},#{phone_number},#{password},#{email},#{state})")
    public void insertUser1(@Param("id")String id,@Param("name")String name,@Param("phone_number")String phone_number,@Param("password")String password,@Param("email")String email,@Param("state")Integer state);
    public void updateUserEmail(String id,String email);
    public void updateUserPwd(String pwd,String id);
    @Select("select * from user where phone_number=#{phone_number} and password =#{password}")
    public com.ykw.parking.pojo1.User queryUser(@Param("phone_number") String phone_number  ,@Param("password") String password);

    @Update("update user set name=#{name} where id=#{id}")
    public int UpdateUserByName(@Param("name") String name  ,@Param("id") String id);


    public int addRC(String ParkingLot_id,String user_id);

    @Update("update parking_lot set identify=#{identify} where id=#{id}")
    public int UpdateRC(String id,int identify);

    @Select("select count(*) from renchou where ParkingLot_id=#{ParkingLot_id} and user_id =#{user_id}")
    public int QueryRC(String ParkingLot_id,String user_id);

    @Select("select count(parkingLot_id) from renchou where  user_id =#{user_id}")
    public int QueryRCAll(String user_id);

    @Insert("insert into users.real_user value(#{id},#{fname},#{phone},#{email},#{rname},#{id_number})")
    public void insertRealUser(String id,String fname,String phone,String email,String rname,String id_number);

    @Insert("insert into users.bank value(#{card},#{user},0.0)")
    public void insertBank(String card,String user);

    @Select("select * from users.bank where user=#{user}")
    public Bank getBank(String user);

    @Update("update users.bank set money=#{money} where user=#{userId}")
    public void addMoney(double money,String userId);

    @Select("select money from users.bank where user=#{userId}")
    public double getMoney(String userId);

    @Insert("insert into user_loan value(#{id},#{name},#{address},#{contact},#{company},#{money},#{interest},#{date},#{uid})")
    public int addLoan(UserLoan userLoan);


    @Select("select * from user_loan where uid=#{uid}")
    public List<UserLoan> getMyLoan(String uid);

    @Update("update user_loan set interest=#{money} where id=#{id}")
    public void updLoan(Double money,String id);

    @Update("update user_loan set interest=0,money=#{money} where id=#{id}")
    public void updLoanBean(Double money,String id);

    @Update("update user_loan set interest=#{interest} where id=#{id}")
    public void updLoanI(Double interest,String id);
    @Select("select * from user_loan where id=#{id}")
    public UserLoan getMyLoanMoney(String id);


    @Select("select * from user_loan")
    public List<UserLoan> getAllLoan();


    @Select("select * from parking_lot where sale=0")
    public List<ParkingLot> getParkingLotRecommend();

}
